package com.sky.zuor.manipulater;


import com.sky.result.Result;
import com.sky.zuor.ZuiruoAssets;
import com.sky.zuor.ZuoruiLoginAndxingu;


import com.sky.zuor.ent.FundsInfoResponse;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;

@RestController
@RequestMapping("admin/zhuoruo/assets")
@Slf4j
public class ZhuoRuiAssetsManipulater {
    @Autowired
    private ZuiruoAssets zuiruoAssets;


    @PostMapping("/funds/get_cash_flow")
    public Result getFlow(@RequestBody ZuiruoAssets.CashFlowRequestV2VO cashFlowRequestV2VO, String token) throws IOException {
        System.out.println("cashFlowRequestV2VO = " + cashFlowRequestV2VO);
        ZuiruoAssets.CashFlowResponse cashFlowResponse = zuiruoAssets.queryCashFlow(cashFlowRequestV2VO, token);
        return Result.success(cashFlowResponse);
    }


    @PostMapping("/funds/get_hold_list")
    public Result getHoldList(@RequestBody ZuiruoAssets.HoldListVO holdListVO, String token) throws IOException {
        ZuiruoAssets.HoldListResponse holdListResponse = zuiruoAssets.queryHoldList(holdListVO,token);
        return Result.success(holdListResponse);
    }


    @PostMapping("/funds/get_stock_margin_ratio")
    public Result getStockMargin(@RequestBody ZuiruoAssets.QueryMarginRatioVO queryMarginRatioVO, String token) throws IOException {
        ZuiruoAssets.MarginRatioResponse stockMarginRatio = zuiruoAssets.getStockMarginRatio(queryMarginRatioVO, token);
        return Result.success(stockMarginRatio);
    }


    @GetMapping("/funds/info")
    public Result getFunds(String token) throws IOException {
        FundsInfoResponse fundsInfo = zuiruoAssets.getFundsInfo(token);
        return Result.success(fundsInfo);
    }

    /**
     * 查询各币种的当前汇率（CNY、HKD、USD）。
     * @param token
     * @return
     * @throws IOException
     */
    @GetMapping("/funds/money_type_list")
    public Result getMoneyType(String token) throws IOException {
        ZuiruoAssets.ExchangeRateResponse moneyTypeList = zuiruoAssets.getMoneyTypeList(token);
        return Result.success(moneyTypeList);
    }
}
